/**
 * @(#)MainContentView.java 2011
 *
 *  Copyright 2011 classic-commerce
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 * @author: <a href="mailto:richard@ioniq.ca">Richard Mutezintare</a>
 *
 */
package ca.ioniq.client.view;

import java.util.ArrayList;
import java.util.HashMap;

import ca.ioniq.client.ClassicMessages;
import ca.ioniq.client.widget.Banner;
import ca.ioniq.client.widget.ErrorMessageWidget;
import ca.ioniq.client.widget.content.BrandSelectorWidget;
import ca.ioniq.client.widget.content.NewsletterWidget;
import ca.ioniq.client.widget.content.RegisterWidget;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Image;

public class MainContentView extends Composite {
    private static String ID = "content";

    private Banner banner;
    private RegisterWidget registerWidget;
    private NewsletterWidget newsletterWidget;
    private BrandSelectorWidget brandSelectorWidget;


    public MainContentView(ErrorMessageWidget errorMessageWidget, ClassicMessages messages) {
        FlowPanel panel = new FlowPanel();

        /*
         TODO initialize list (list of URIs to images) in the presenter from the server on application startup
        */
        banner = new Banner(new ArrayList<Image>());
        panel.add(banner);

        registerWidget = new RegisterWidget(new ErrorMessageWidget(messages), messages);
        registerWidget.setVisible(false);
        panel.add(registerWidget);


        newsletterWidget = new NewsletterWidget(new ErrorMessageWidget(messages), messages);
        panel.add(newsletterWidget);

        brandSelectorWidget = new BrandSelectorWidget(new HashMap<Image, Integer>());
        panel.add(brandSelectorWidget);

        panel.getElement()  .setId(ID);
        initWidget(panel);

    }

    public RegisterWidget getRegisterWidget() {
        return registerWidget;
    }

    public Banner getBanner() { return banner; }

    public NewsletterWidget getNewsletterWidget() {
        return newsletterWidget;
    }

    public BrandSelectorWidget getBrandSelectorWidget() {
        return brandSelectorWidget;
    }
}
